#pragma once

#ifndef ROCKFALL_H
#define ROCKFALL_H

#include <map>
#include <stdlib.h>
#include "Game.h"
#include "Level.h"
#include "Player.h"
#include "BatEnemy.h"
#include "YetiEnemy.h"
#include "EntityManager.h"
#include "MessageHandler.h"
#include "Animation.h"
#include "AnimationPlayer.h"
#include "ForceRegistry.h"
#include "LevelManager.h"
#include "LevelSwitcher.h"
#include "StateMachine.h"
#include "Ladder.h"
#include "Menus.h"
#include "VertexPosTex.h"

class RockFall : public Game
{
private:
	D3DVIEWPORT9 viewport;
	// Used for menu textures & objects.
	IDirect3DTexture9* backgroundText;
	IDirect3DTexture9* smStartOn;
	IDirect3DTexture9* smInstructionOn;
	IDirect3DTexture9* smExitOn;
	IDirect3DTexture9* pmResumeOn;
	IDirect3DTexture9* pmInstructionOn;
	IDirect3DTexture9* pmExitOn;
	IDirect3DTexture9* instuctions;
	IDirect3DTexture9* winning;
	IDirect3DTexture9* losing;
public:
	// Menus screens.
	Menus* startMenu;
	Menus* pauseMenu;
	Menus* instrcutionScreen;
	Menus* winScreen;
	// Used when during instruction screen navigation.
	bool startPause;
	// Statem machine.
	StateMachine<RockFall> stateMachine;
	// Used for ladder texture & ladder entites.
	IDirect3DTexture9* ladderTexture;
	std::list<Ladder*> ladders0;
	std::list<Ladder*> ladders1;
	std::list<Ladder*> ladders2;
	int prevLevel;
	// Used for weapon textures;
	IDirect3DTexture9* rockTexture;
	IDirect3DTexture9* melleTexture;
	D3DXVECTOR3 levelPosition;
private:
	// Used for levels & level entities.
	IDirect3DTexture9* tiles;
	TileSet* tileSet;
	Level* level00;
	Level* level01;
	Level* level02;
	LevelSwitcher* startPoint;
	LevelSwitcher* endPoint;
	IDirect3DTexture9* startTexture;
	IDirect3DTexture9* endTexture;
	// Used for player & player animations.
	IDirect3DTexture9* attackTexture;
	IDirect3DTexture9* climbTexture;
	IDirect3DTexture9* dieTexture;
	IDirect3DTexture9* idleTexture;
	IDirect3DTexture9* interactTexture;
	IDirect3DTexture9* jumpTexture;
	IDirect3DTexture9* runTexture;
	Player* player;
	// Used for bat enemy texture entities.
	IDirect3DTexture9* batIdleTexture;
	IDirect3DTexture9* batAttackTexture;
	std::map<int,std::list<D3DXVECTOR3>> batZones0;
	std::map<int,std::list<D3DXVECTOR3>> batZones1;
	std::list<BatEnemy*> bats0;
	std::list<BatEnemy*> bats1;
	int numBats;
	// Used for yeti enemy texture & entities
	IDirect3DTexture9* yetiIdleTexture;
	IDirect3DTexture9* yetiMoveTexture;
	IDirect3DTexture9* yetiAttackTexture;
	IDirect3DTexture9* yetiHitTexture;
	IDirect3DTexture9* yetiDieTexture;
	AnimationPlayer* yetiAnims;
	YetiEnemy* yeti;
	// Used for render targets.
	ID3DXRenderToSurface* mRTSone;
	IDirect3DTexture9* mTexOne;
	IDirect3DSurface9* mTopSurfOne;
	ID3DXRenderToSurface* mRTStwo;
	IDirect3DTexture9* mTexTwo;
	IDirect3DSurface9* mTopSurfTwo;
	// Used for lighting effects.
	IDirect3DTexture9* torch;
	IDirect3DTexture9* clear;
	IDirect3DVertexDeclaration9* decl;
	// Effect file
	ID3DXEffect* lightEffect;
	D3DXHANDLE lightTexture;
	D3DXHANDLE gameTexture;
	D3DXHANDLE time;
	D3DXHANDLE technique;
	IDirect3DVertexBuffer9* vertexBuffer;
public:
	RockFall(HINSTANCE hInstance, int nShowCmd);
	void setLevelPosition(D3DXVECTOR3 newLevelPos) { levelPosition = newLevelPos; }
	virtual ~RockFall();
	void initialise() { }
	void loadContent();
	void update(float frameTime);
	void render();
	void unloadContent();
};

#endif